$(function(){
	page.getAdminProcess('');
	//绑定按钮事件
	page.bind();
	//加载生产线
	page.getProductionLine('1');
	//加载车间名称
	page.getWorkshopName("");
	//加载工序名称
	page.getProcessName('');
	page.getRowMaterialType();
	page.removeBtnBind();
	page.getAllPerson();
	queryProcess(myTrim($("#search-input").val()),'1');
});
var materialTypeArray=null;
var processingObjectOptions = "";
function successRollBack(data){
	console.log(data);
	layAlert("上传成功,请刷新页面查看,如果未能导入数据,请确定填入的部门或车间是已存在的");
	tableListData.ajax.reload( null, false);
}
var reviewersArr;
var page = {
	bind:function(){
		$("#isNeedReviewed").bind("change",function(){
			if($(this).val()==1){
				$("#reviewersTr").show("slow");
			}else{//如果不需要审核则隐藏可审核人
				$("#reviewersTr").hide("slow");
			}
		});
		//点击可审核人按钮，打开模态框
		$("#reviewers").bind("click",function(){
			$("#reviewersModal").modal("show");
		});
		//可审核人模态框显示
		$("#reviewersModal").on("show.bs.modal",function(){
			$("#reviewers .pad").each(function(){
				$("#reviewersModal .right-box").append($("#reviewersModal .left-box").find('[value="'+$(this).attr("value")+'"]'));
			});
		});
		//可审核人模态框隐藏
		$("#reviewersModal").on("hidden.bs.modal",function(){
			$("#reviewersModal .left-box").append($("#reviewersModal .right-box").find('.item').removeClass('selected-item'));
		});
		//导入工序模态框隐藏
		$("#importProcessModal").on("hidden.bs.modal",function(){
			$(".right-box").find('.item').removeClass('selected-item');
		});
		//选择可审核人模态框确定按钮
		$("#reviewersModalBtn").bind("click",function(){
			var html = "";
			reviewersArr = [];
			$("#reviewersModal .right-box li").each(function(){
				html+="<button class='btn btn-success radius pad' value='"+$(this).attr("value")+"'>"+$(this).text()+"</button>&nbsp;";
				reviewersArr.push({'userName':$(this).text(),'userId':$(this).attr("value")});
			});	
			console.log(reviewersArr);
			if(html.length>0){
				$("#reviewers").html("");
				$("#reviewers").html(html);
			}else{
				$("#reviewers").html("<button class='btn btn-primary radius'>选择可审核人</button>");
			}
			$("#reviewersModal").modal("hide");
		});
		$("#importProcessModal .left-box").on("click",'#importSearchBtn',function(){
			var searchText = $("#importSearchText").val();
			page.getAdminProcess(searchText).then(function(){
				$("#importSearchText").val(searchText);
			});
		});
		$("#import").bind("click",function(){
			$("#importProcessModal").modal("show");
		});
		$("#addModalBtn").bind("click",function(){
			var processStr = "";
			$("#importProcessModal .right-box li.item").each(function(){
				processStr+=$(this).attr("value")+",";
			});	
			processStr = processStr.substring(0,processStr.length-1);
			console.log(processStr);
			if(processStr.length<=0){
				layAlert("没有选择要导入的新工序");
				return false;
			}
			ajaxUtil.ajaxRuquest("basicData/importprocess",{'processStr':processStr},function(data){
				layAlert(data);
			});
			page.getProductionLine('1');
			page.getWorkshopName("");
			page.getProcessName('');
			page.getAdminProcess("");
			tableListData.ajax.reload(null,false);
			$("#importProcessModal").modal("hide");
		});
		$("#search-input").keyup(function(event){
			var searchText = myTrim($("#search-input").val());
			setTimeout(function(){
				queryProcess(searchText,$("#view").val());
			},300);
		});
		//点击搜索按钮
		$("#searchBtn").bind("click",function(){
			queryProcess(myTrim($("#search-input").val()),$("#view").val());
		});
		//点击切换查看状态按钮
		$("#view").bind("click",function(){
			var view = $("#view").val();
			if(view=="1"){
				view = "0";
			}else{
				view = "1";
			}
			queryProcess(myTrim($("#search-input").val()),view);
			$("#view").val(view);
		});
		//上传按钮
		$("#addProcessFile").bind("click",function(){
			var fileName=$("#filename").val();
			if(!fileName){
				layAlert("请选择上传文件");
				return false;
			}
			ajaxUtil.fileAjax('procedure/addProcessByFile','filename',function(){
				layAlert("上传成功");
				tableListData.ajax.reload( null, false);
			});
		});
		//改变生产线时
		$("#productionLine").bind("change",function(){
			var productionLine = $("#productionLine").val();
			var workshopName = $("#workshopName").val();
			if($(this).val() != '请选择' && $(this).val() != ''){
				page.getWorkshopNameByDeptId(productionLine,$("#view").val());
			}
		});
		//改变车间名称时
		$("#workshopName").bind("change",function(){
			var productionLine = $("#productionLine").val();
			var workshopName = $("#workshopName").val();
			var processName = $("#processName").val();
			//改变车间时获取工序名称
			if($(this).val()!='请选择' && $(this).val()!=''){
				page.getProcessName(workshopName);
			}
		});
		
		//改变工序名称时
		$("#processName").bind("change",function(){
			var productionLine = $("#productionLine").val();
			var workshopName = $("#workshopName").val();
			var processName = $("#processName").val();
		});
		//点击添加按钮时
		$("#insertBtn").bind("click",function(){
			var ob = page.insertAndUpdateParam();
			if(!ob){
				return false;
			}
			ajaxUtil.ajaxRuquest(
					'procedure/insertProcess',
					ob,
					function(data){
						//点击提交按钮后刷新表
						page.getProductionLine('1');
						page.getWorkshopName("");
						page.getProcessName('');
						page.getAdminProcess("");
						tableListData.ajax.reload( null, false);
						layAlert("添加成功");
					}
			);
		});
		//点击修改按钮时
		$("#updateBtn").bind("click",function(){
			var ob = page.insertAndUpdateParam();
			if(!ob){
				return false;
			}
			if(cantUpdate=='交接入库' || cantUpdate=='交接出库'){
				if(cantUpdate!=$("#processName").val()){
					layer.msg("工序名'交接入库'与'交接出库'不允许修改");
					return false;
				}
			}
			ajaxUtil.ajaxRuquest(
					'procedure/updateProcessByCode',
					ob,
					function(data){
						//点击按钮后刷新表
						page.getProductionLine('1');
						page.getWorkshopName("");
						page.getProcessName('');
						page.getAdminProcess("");
						tableListData.ajax.reload( null, false);
						layAlert("修改成功");
					}
			);
		});
	},
	//获取所有用户
	getAllPerson:function(){
		return ajaxUtil.ajaxRequest('basicData/getPersonName',{'view':1}).then(
		function(data){
			console.log(data);
			for(var i=0,l=data.length;i<l;i++){
				$("#reviewersModal .left-box").append("<li class='item ui-sortable-handle' value='"+data[i].id+"' >"+data[i].personName+"</li>");
			}
			page.leftAndRightBind();
		});
	},
	getRowMaterialType: function () {
        return ajaxUtil.ajaxRequest('basicData/getRowMaterialType', {"isvolid":1}).then(function (data) {
        	console.log(data);
        	materialTypeArray=data;
            var html = "";
            for (var i = 0; i < data.length; i++) {
                html += "<option value='" + data[i] + "'>" + data[i] + "</option>";
            }
            html += "<option value='款'>款</option>";
            materialTypeArray.push("款");
            $("#materialDataList").html("");
            $("#materialDataList").append(html);
            processingObjectOptions = html;
        });
    },
	//获取admin公司的工序
	getAdminProcess:function(searchText){
		return ajaxUtil.ajaxRequest('basicData/getAdminProcess',{'searchText':searchText}).then(
		function(data){
			console.log(data);
			$("#importProcessModal .left-box").html("<input id='importSearchText' type='text' placeholder='部门/车间/工序名称' style='width:140px;'/><span id='importSearchBtn' class='btn'>搜索</span>");
			for(var i=0,l=data.length;i<l;i++){
				$("#importProcessModal .left-box").append("<li class='item ui-sortable-handle' value='"+data[i].id+"' >"+data[i].productionLine+" "+data[i].workshopName+" "+data[i].processName+"</li>");
			}
			page.leftAndRightBind();
		});
	},
	//左右移动
	leftAndRightBind:function(){
		$(".item").unbind("click");
		$(".left-box .item").unbind("dblclick");
		$(".right-box .item").unbind("dblclick");
		//单击
		$("#importProcessModal .item").bind("click",function(){
			$(this).toggleClass("selected-item");
		});
		//左边双击右移
		$("#importProcessModal .left-box .item").bind("dblclick",function(){
			$("#importProcessModal .right-box").append($(this).removeClass('selected-item'));
			page.leftAndRightBind();
		});
		//右边双击左移
		$("#importProcessModal .right-box .item").bind("dblclick",function(){
			$("#importProcessModal .left-box").append($(this).removeClass('selected-item'));
			page.leftAndRightBind();
		});
		//单击
		$("#reviewersModal .item").bind("click",function(){
			$(this).toggleClass("selected-item");
		});
		//左边双击右移
		$("#reviewersModal .left-box .item").bind("dblclick",function(){
			$("#reviewersModal .right-box").append($(this).removeClass('selected-item'));
			page.leftAndRightBind();
		});
		//右边双击左移
		$("#reviewersModal .right-box .item").bind("dblclick",function(){
			$("#reviewersModal .left-box").append($(this).removeClass('selected-item'));
			page.leftAndRightBind();
		});
	},
	removeBtnBind:function(){
		$("#importProcessModal .add-one").bind("click",function(){
			$("#importProcessModal .right-box").append($("#importProcessModal .left-box").find('.selected-item').removeClass('selected-item'));
		});
		$("#importProcessModal .add-all").bind("click",function(){
			$("#importProcessModal .right-box").append($("#importProcessModal .left-box").find('.item').removeClass('selected-item'));
		});
		$("#importProcessModal .remove-one").bind("click",function(){
			$("#importProcessModal .left-box").append($("#importProcessModal .right-box").find('.selected-item').removeClass('selected-item'));
		});
		$("#importProcessModal .remove-all").bind("click",function(){
			$("#importProcessModal .left-box").append($("#importProcessModal .right-box").find('.item').removeClass('selected-item'));
		});
		
		$("#reviewersModal .add-one").bind("click",function(){
			$("#reviewersModal .right-box").append($("#reviewersModal .left-box").find('.selected-item').removeClass('selected-item'));
		});
		$("#reviewersModal .add-all").bind("click",function(){
			$("#reviewersModal .right-box").append($("#reviewersModal .left-box").find('.item').removeClass('selected-item'));
		});
		$("#reviewersModal .remove-one").bind("click",function(){
			$("#reviewersModal .left-box").append($("#reviewersModal .right-box").find('.selected-item').removeClass('selected-item'));
		});
		$("#reviewersModal .remove-all").bind("click",function(){
			$("#reviewersModal .left-box").append($("#reviewersModal .right-box").find('.item').removeClass('selected-item'));
		});
	},
	//获取生产线填入productionLine控件中
	getProductionLine:function(view){
		ajaxUtil.ajaxRuquest('basicData/getDeptName',
				{'view':view},
				function(data){
					deptArray = data;
					var html = "<option>请选择</option>";
					for(var i=0;i<data.length;i++){
						html = html+"<option value='"+data[i].id+"'>"+data[i].deptName+"</option>"
						deptArray = data;
					}
					$("#productionLine").html("");
					$("#productionLine").append(html);
				});
	},
	//从车间生产周期表中获取车间名称填入workshopName控件中
	getWorkshopName:function(deptId){
		ajaxUtil.ajaxRuquest('basicData/getWorkshop',
				{'deptId':deptId},function(data){
			var html = "<option>请选择</option>";
			console.log(data);
			for(var i=0;i<data.length;i++){
				html = html+"<option value='"+data[i].id+"'>"+data[i].workshopName+"</option>"
				thArray.push(data[i]);
			}
			$("#workshopName").html("");
			$("#workshopName").append(html);
		});
		console.log(thArray);
		thArray.length = 0;
	},
	getWorkshopNameByDeptId:function(deptId,view){
		ajaxUtil.ajaxAsyncRuquest('basicData/getWorkshopName',
				{'deptId':deptId,'view':view},function(data){
			var html = "<option>请选择</option>";
			thArray = data;
			for(var i=0;i<data.length;i++){
				html = html+"<option value='"+data[i].id+"'>"+data[i].workshopName+"</option>"
			}
			$("#workshopName").html("");
			$("#workshopName").append(html);
		});
	},
	//根据车间名称获取工序名称
	getProcessName:function(workshopName){
		ajaxUtil.ajaxRuquest('basicData/getWorkingProcedureName',
				{'workshopName':workshopName},
				function(data){
					var html = "";
					for(var i=0;i<data.length;i++){
						html = html+"<option value='"+data[i]+"'>"+data[i]+"</option>";
					}
					$("#processNameList").html("");
					$("#processNameList").append(html);
				});
	},
	//query点击行，获取id，getDetail(id)
	getProcessDetail:function(id){
		ajaxUtil.ajaxRuquest(
				'basicData/getProcessDetail',
				{
					'id':id
				},
				function(data){
					if(data!=""){
						console.log(data[0]);
						//当返回数据不为空时
						page.getWorkshopNameByDeptId(data[0].productionLine,"1");
						$("#updateBtn").val(data[0].id);//为修改按钮添加此工序id
						$("#workingProcedureDuration").val(data[0].workingProcedureDuration);
						$("#productionLine").val(data[0].productionLine);
						$("#workshopName").val(data[0].workshopName);
						$("#processName").val(data[0].processName);
						$("#status").val(data[0].status);
						$("#processingObject").val(data[0].processingObject);
						if(data[0].processName=="交接入库" || data[0].processName=="交接出库"){
							$("#processingObject").val("所有");
							$("#processingObject").attr("disabled", true);
							$("#materialDataList").html("");
						}else{
							$("#processingObject").attr("disabled", false);
							$("#materialDataList").html(processingObjectOptions);
						}
						$("#isNeedReviewed").attr("disabled", false);
						$("#isNeedReviewed").val(data[0].isNeedReviewed);
						if(data[0].isNeedReviewed==1){
							$("#reviewersTr").show("slow");
						}else{
							$("#reviewersTr").hide("slow");
						}
						cantUpdate = data[0].processName;
						$("#sort").val(data[0].sort);
						$("#chargeUnit").val(data[0].chargeUnit);
						$("#unitPrice").val(data[0].unitPrice);
						
						var reviewerList = data[0].reviewerList;
						var html = "";
						reviewersArr = [];
						for (var i = 0,length=reviewerList.length; i < length; i++) {
							html+="<button class='btn btn-success radius pad' value='"+reviewerList[i].approverId+"'>"+reviewerList[i].approverName+"</button>&nbsp;";
							reviewersArr.push({'userName':reviewerList[i].approverName,'userId':reviewerList[i].approverId});
						}
						if(html.length>0){
							$("#reviewers").html("");
							$("#reviewers").html(html);
						}else{
							$("#reviewers").html("<button class='btn btn-primary radius'>选择可审核人</button>");
						}
						
						$("#processCode").val(data[0].processCode);
						$("#creater").val(data[0].creater);
						$("#creationTime").val(data[0].creationTime);
						$("#lastModifyTime").val(data[0].lastModifyTime);
						$("#lastModifier").val(data[0].lastModifier);
						$("#auditTime").val(data[0].auditTime);
						$("#auditor").val(data[0].auditor);
						$("#orderNumber").val(data[0].orderNumber);
					}
				}
		);
	},
	//插入和修改要传入的参数
	insertAndUpdateParam:function(){
		var id = $("#updateBtn").val();
		var processCode = $("#processCode").val();
		var productionLine = $("#productionLine").val();
		if(productionLine=="请选择"){
			layAlert("请选择部门");
			return false;
		}
		var workshopName = $("#workshopName option:selected").text();
		if(workshopName=="请选择"){
			layAlert("请选择车间名称");
			return false;
		}
		workshopName = $("#workshopName").val();
		var processName = $("#processName").val();
		if(processName==''){
			layAlert("请选择或输入工序名称");
			return false;
		}
		var status = $("#status").val();
		if(status=="请选择"){
			layAlert("请选择状态");
			return false;
		}
		var processingObject = $("#processingObject").val();
		if(processingObject=="" && status!='禁用'){
			layAlert("请选择加工对象");
			return false;
		}
		if((processName=='交接入库' || processName=='交接出库')){
			 if(processingObject!='所有'){
				 layAlert("交接出入库加工对象只能是所有");
				 return false;
			 }
		}else{
			if($.inArray(processingObject, materialTypeArray)==-1 && status!='禁用' ){
				layAlert("此加工对象不存在");
				return  false;
			}
		}
		var workingProcedureDuration = $("#workingProcedureDuration").val();
		if(workingProcedureDuration!="" && /^\d+(\.\d+)?$/.test(workingProcedureDuration)==false){
			layer.msg("工序作业时间格式规范不正确");
			return false;
		}
		var sort = $("#sort").val();
		if(sort!="" && /^\d+$/.test(sort)==false){
			layer.msg("顺序只能是正整数");
			return false;
		}
		var chargeUnit = $("#chargeUnit").val();
		var unitPrice = $("#unitPrice").val();
		if(unitPrice!="" && /^\d+(\.\d+)?$/.test(unitPrice)==false){
			layer.msg("单价只能是正整数");
			return false;
		}
		var temp = $("#productionLine").find("option:selected").text();
		var isNeedReviewed = $("#isNeedReviewed").val();
//		if(processName=="交接出库" || processName=="交接入库"){
//			if(isNeedReviewed!=1){
//				layAlert("工序'交接出/入库'不能设置为'无需审核'");
//				return false;
//			}
//		}
		if(isNeedReviewed==1){
			var reviewers = JSON.stringify(reviewersArr);
		}else{
			var reviewers = null;
		}
		var sendData = {
				'id':id,
				'processCode':processCode,
				'productionLine':productionLine,
				'workshopName':workshopName,
				'processName':processName,
				'processingObject':processingObject,
				'workingProcedureDuration':workingProcedureDuration,
				'sort':sort,
				'status':status,
				'chargeUnit':chargeUnit,
				'unitPrice':unitPrice,
				'temp':temp, //仅用于insertProcess时getProcessDetail()
				'isNeedReviewed':isNeedReviewed,
				'reviewers':reviewers
		}
		return sendData;
	}
}

var cantUpdate;//全局变量用于判断交接入库与交接出库工序名称不能修改
var thArray=[];//保存查询工序结果
var tableData=[];//保存查询工序结果
//查询所有工序
var tableListData;
function queryProcess(searchText,view){
	if(searchText != $("#search-input").val()){
		return;
	}
	$('.save-btn').unbind("click"); 
	$('#queryProcessTable tbody').unbind("click"); 
	$('.edit-btn').unbind("click"); 
	$('#batch-edit-btn').unbind("click"); 
	$('#batch-delete-btn').unbind("click"); 
	$('#batch-calen-btn').unbind("click"); 
	$('#batch-save-btn').unbind("click"); 
	
	tableListData = ajaxUtil.dataTablesAjax("queryProcessTable",20,"basicData/queryProcess",
			{'searchText':searchText,
			'view':view},
			[
			{"data":"productionLine"},
			{"data":"workshopName"},
			{"data":"processName"},
			{"data":"status"}
//			{"data": "id", render:function(data){
//			   return "<button class='edit-btn btn' type='button' value='"+data+"'>编辑</button>"
//			} 
//			}
	]);
	//行点击事件
	var table = $('#queryProcessTable').DataTable();
	$('#queryProcessTable tbody').on('click', 'tr', function () {
        var data = table.row(this).data();
        var id = data.id;
        console.log("id:"+id);
        page.getProcessDetail(id);
    } );
	//点击编辑按钮
    $("#queryProcessTable tbody").on("click",".edit-btn",function(){
    	
    	var tds=$(this).parents("tr").children();
    	var twoArray=new Array();
    	twoArray.push('使用');
    	twoArray.push('禁用');
    	var id=$(this).val();
        var productionLine=$(this).parents().children('td').eq(0).text();
        var workshopName=$(this).parents().children('td').eq(1).text();
        var processName=$(this).parents().children('td').eq(2).text();
        var status=$(this).parents().children('td').eq(3).text();
        var id=$(this).val();
        cantUpdate = processName;
        ajaxUtil.ajaxAsyncRuquest('basicData/getDeptId2',
				{'deptName':productionLine},function(data){
			thArray = data;
		});
        console.log(thArray);
        $(this).parents().children('td').eq(0).html(selectTed(deptArray,productionLine));
        $(this).parents().children('td').eq(1).html(selectWorkshop(thArray,workshopName));
        $(this).parents().children('td').eq(2).html("<input class='input-text widthtd' type='text' value='"+processName+"' />");
        $(this).parents().children('td').eq(3).html(select(twoArray,status));
        $(this).parents().children('td').eq(4).html("<button class='save-btn btn' type='button' value='"+id+"'>保存</button>");
    });
    //点击保存按钮
    $("#queryProcessTable tbody").on("click",".save-btn",function(){
    	var id=$(this).val();
        var productionLine=$(this).parents().children('td').eq(0).children('select').val();
        var workshopName=$(this).parents().children('td').eq(1).children('select').val();
        var processName=$(this).parents().children('td').eq(2).children('input').val();
        var status=$(this).parents().children('td').eq(3).children('select').val();
        var tds=$(this).parents("tr").children();
        if(cantUpdate=='交接入库' || cantUpdate=='交接出库'){
			if(cantUpdate!=processName){
				layAlert("工序名'交接入库'与'交接出库'不允许修改");
				return false;
			}
		}
        ajaxUtil.ajaxRuquest(
				'procedure/updateProcessByCode',
				{
					'productionLine':productionLine,
					'workshopName':workshopName,
					'processName':processName,
					'status':status,
					'id':id
				},
				function(data){
					//点击提交按钮后刷新表
					page.getProductionLine('1');
					page.getWorkshopName("");
					page.getProcessName('');
					page.getAdminProcess("");
					tableListData.ajax.reload( null, false);
					layAlert("修改成功");
				}
		);
        $(this).html("编辑");
        $("#queryProcessTable tbody").html("");
        tableListData.ajax.reload( null, false);
    });


    //点击批量编辑按钮
    $("#batch-edit-btn").click(function(){
    	var twoArray=new Array();
    	twoArray.push('使用');
    	twoArray.push('禁用');
    	var nTrs = $('#queryProcessTable').dataTable().fnGetData();//fnGetNodes获取表格所有行，nTrs[i]表示第i行tr对象  
        var html="";
        
    	for(var i = 0; i < nTrs.length; i++){  
    		html+="<tr><td>"+selectTed(deptArray,nTrs[i].productionLine)+
    		      "</td><td>"+selectWorkshop(thArray,nTrs[i].workshopName)+
    		      "</td><td><input class='input-text widthtd' type='text' value='"+nTrs[i].processName+"' />"+
    		      "</td><td>"+select(twoArray,nTrs[i].status)+
    		      "</td><td><input name='checkUpdate'  type='checkbox' value='"+nTrs[i].id+"' /></td></tr>"
        } 
    	$("#queryProcessTableTbody").html(html);
    });
    $("#batch-delete-btn").click(function(){//删除功能取消
    	var idArray=new Array(); 
    	$("[name='checkUpdate']:checked").each(function(){  
    		idArray.push($(this).val());  
    	});  
    	if(idArray.length<=0){
    		layAlert("请选择操作对象");
    		return false;
    	}
    	 ajaxUtil.ajaxRuquest('procedure/deleteAllProcess',{'idArray':JSON.stringify(idArray)},function(data){
	            layAlert(data);
	            tableListData.ajax.reload( null, false); 
			}
	     );
    });
    
    
    //点击取消按钮时
    $("#batch-calen-btn").click(function(){
    	tableListData.ajax.reload( null, false); 
    });
    //点击批量保存按钮时
    $("#batch-save-btn").click(function(){
    	var beanArray=new Array();
    	//获取选中行
    	$("[name='checkUpdate']:checked").each(function(){  
    		var bean=new Object();
    		bean.id=$(this).val();
    		bean.productionLine=$(this).parents().children('td').eq(0).children('select').val();
    		bean.workshopName=$(this).parents().children('td').eq(1).children('select').val();
    		bean.processName=$(this).parents().children('td').eq(2).children('input').val();
    		bean.status=$(this).parents().children('td').eq(3).children('select').val();
    		beanArray.push(bean);
	    }); 
    	if(beanArray.length<=0){
    		layAlert("请选择要操作的对象");
    		return false;
    	}
    	 ajaxUtil.ajaxRuquest('procedure/updateAllProcessByCode',{'beanArray':JSON.stringify(beanArray)},function(data){
					 layAlert(data);
					 page.getProductionLine('1');
					 page.getWorkshopName("");
					 page.getProcessName('');
					 page.getAdminProcess("");
    		         tableListData.ajax.reload( null, false);
 				}
 		);
    });

}

function selectTed(thArray,workShop){
	var selectHtml="<select class='input-text widthtd'><option value=''>无</option>";
	for(var j=0;j<thArray.length;j++){
		if(thArray[j].deptName==workShop){
			selectHtml += "<option selected='selected' value='"+thArray[j].id+"'>"+thArray[j].deptName+"</option>";
		}else{
			selectHtml += "<option value='"+thArray[j].id+"'>"+thArray[j].deptName+"</option>";
		}
	}
	selectHtml+="</select>"
    return selectHtml;
}
function selectWorkshop(thArray,workShop){
	var selectHtml="<select class='input-text widthtd'>";
	for(var j=0;j<thArray.length;j++){
		if(thArray[j].workshopName==workShop){
			selectHtml += "<option selected='selected' value='"+thArray[j].id+"'>"+thArray[j].workshopName+"</option>";
		}else{
			selectHtml += "<option value='"+thArray[j].id+"'>"+thArray[j].workshopName+"</option>";
		}
	}
	selectHtml+="</select>"
    return selectHtml;
}
function select(thArray,workShop){
	var selectHtml="<select class='input-text widthtd'>";
	for(var j=0;j<thArray.length;j++){
		if(thArray[j]==workShop){
			selectHtml += "<option selected='selected' value='"+thArray[j]+"'>"+thArray[j]+"</option>";
		}else{
			selectHtml += "<option value='"+thArray[j]+"'>"+thArray[j]+"</option>";
		}
	}
	selectHtml+="</select>"
    return selectHtml;
}
var deptArray;
//获取部门名称
function getDeptName(){
	ajaxUtil.ajaxRuquest("basicData/getDeptName",null,function(data){
		deptArray=data;
	});
}


